<template>
  <!-- 异常列表 -->
  <el-table :data="tableData" style="width: 100%">
    <el-table-column fixed prop="id" label="id" width="150"/>
    <el-table-column prop="userId" label="用户id" width="120"/>
    <el-table-column label="图片" width="120" #default="scope">
      <img v-for="item in scope.row.imagesList" :src="item" alt="" width="50" height="50">
    </el-table-column>
    <el-table-column prop="status" label="状态" width="120"/>
    <el-table-column prop="responce" label="回复" width="120"/>
    <el-table-column prop="createTime" label="上报时间" width="120"/>
    <el-table-column fixed="right" label="Operations" min-width="120">
      <template #default="ue">
        <el-button link type="primary" size="small" @click="handle(ue.row)">
          处理
        </el-button>
      </template>
    </el-table-column>
  </el-table>

  <el-dialog
      v-model="dialogVisible"
      title="Tips"
      width="500"
      :before-close="handleClose"
  >
    <span>异常处理</span>
    <el-form :model="form" label-width="auto" style="max-width: 600px">
      <el-form-item label="响应">
        <el-input v-model="form.responce" />
      </el-form-item>
      <el-button @click="HandleException">提交</el-button>
    </el-form>
  </el-dialog>

</template>

<script setup>
import {getExceptionList, handleException} from '@/api/staff';
import {ref} from 'vue';
import {ElMessage} from "element-plus";

const tableData = ref([])
const dialogVisible = ref(false)
const form = ref({
  id:"",
  images:"",
  status:"",
  userId:"",
  responce:"",
  text:"",
  createTime:""
})


GetExceptionList()

function GetExceptionList() {
  getExceptionList().then(res => {
    if (res.data.code == 200000) {
      tableData.value = res.data.data
    }
  })
}

function handle(data){
  dialogVisible.value = true;
  form.value = data;
}

function HandleException(){
  handleException(form.value).then(res => {
    if(res.data.code == 200000){
      dialogVisible.value = false;
      GetExceptionList()
      ElMessage({
        message: res.data.msg,
        type: 'success'
      });
    }
  })
}
</script>


<style>


</style>